package tests;

import tester.Example;
import tester.TestMethod;
import tester.Tester;
import tester.utilities.TesterUtility;

@Example
public class PrimitiveTests {

	@TestMethod
	public void testPrimitiveCloneSuccess(Tester t){
		int x = 5;
		int y = TesterUtility.objectCopy(x);
		t.checkExpect(x, y);

		Integer q = new Integer(10);
		Integer qCopy = TesterUtility.objectCopy(q);
		t.checkExpect(q, qCopy);

		Double doubleObject = new Double(4.03232);
		Double doubleObjectCopy = TesterUtility.objectCopy(doubleObject);
		t.checkExpect(doubleObject, doubleObjectCopy);

		double primDouble = 5.23;
		double primDoubleCopy = TesterUtility.objectCopy(primDouble);
		t.checkExpect(primDouble, primDoubleCopy);

		Boolean b = new Boolean(true);
		Boolean bCopy = TesterUtility.objectCopy(b);
		t.checkExpect(b, bCopy);

		boolean bool = false;
		boolean boolCopy = TesterUtility.objectCopy(bool);
		t.checkExpect(bool, boolCopy);

		byte by = 4;
		byte byCopy = TesterUtility.objectCopy(by);
		t.checkExpect(by, byCopy);

		Byte bigByte = new Byte(by);
		Byte bigByteCopy = TesterUtility.objectCopy(bigByte);
		t.checkExpect(bigByte, bigByteCopy);
		
		char c = 'a';
		char cCopy = TesterUtility.objectCopy(c);
		t.checkExpect(c, cCopy);

		long l = 12013;
		long lCopy = TesterUtility.objectCopy(l);
		t.checkExpect(l, lCopy);

		short s = 124;
		short sCopy = TesterUtility.objectCopy(s);
		t.checkExpect(s, sCopy);
		
		String foo = "foo";
		String fooCopy = TesterUtility.objectCopy(foo);
		t.checkExpect(foo, fooCopy);
	}
	
	public void cloneFailureTestsPrimitives(Tester t){
		int x = 5;
		int y = TesterUtility.objectCopy(x);
		x = 9;
		t.checkExpect(x, y);

		Integer q = new Integer(10);
		Integer qCopy = TesterUtility.objectCopy(q);
		q = new Integer(12);
		t.checkExpect(q, qCopy);

		Double doubleObject = new Double(4.03232);
		Double doubleObjectCopy = TesterUtility.objectCopy(doubleObject);
		doubleObject = new Double(3.2);
		t.checkExpect(doubleObject, doubleObjectCopy);

		double primDouble = 5.23;
		double primDoubleCopy = TesterUtility.objectCopy(primDouble);
		primDouble = 4.2;
		t.checkExpect(primDouble, primDoubleCopy);

		Boolean b = new Boolean(true);
		Boolean bCopy = TesterUtility.objectCopy(b);
		b = new Boolean(false);
		t.checkExpect(b, bCopy);

		boolean bool = false;
		boolean boolCopy = TesterUtility.objectCopy(bool);
		bool = true;
		t.checkExpect(bool, boolCopy);

		byte by = 44;
		byte byCopy = TesterUtility.objectCopy(by);
		by = 42;
		t.checkExpect(by, byCopy);

		byte bbb = 100;
		Byte bigByte = new Byte(bbb);
		Byte bigByteCopy = TesterUtility.objectCopy(bbb);
		byte bbb1 = 99;
		bigByte = new Byte(bbb1);
		t.checkExpect(bigByte, bigByteCopy);
		
		char c = 'a';
		char cCopy = TesterUtility.objectCopy(c);
		c = 'b';
		t.checkExpect(c, cCopy);

		long l = 12013;
		long lCopy = TesterUtility.objectCopy(l);
		l = 323;
		t.checkExpect(l, lCopy);

		short s = 124;
		short sCopy = TesterUtility.objectCopy(s);
		s = 1;
		t.checkExpect(s, sCopy);
		
		String foo = "foo";
		String fooCopy = TesterUtility.objectCopy(foo);
		foo = "fee";
		t.checkExpect(foo, fooCopy);
		
	}
}
